<template>
	<view class="order_wrap">
		<!-- 采购订单 -->
		<view class="wrap" v-if="orderList">
			<!-- <u-card margin='0rpx'> -->
			<view class="" slot="body">
				<view class="title-wrap">
					<view class="orderinfo-contaienr">
						<view class="title  add">
							<view class="font-weight-bold">订单信息：</view>
							<view class="texta">{{ orderList.remark }}</view>
						</view>
						<view class="menu_itemCopy-container">
							<view class="menu_itemCopy" @click="copyOrderInfo">
								<text>复制</text>
							</view>
						</view>
					</view>
					<!-- <view class="title u-line-2 add"><text class="font-weight-bold">订单编号：</text>{{ orderList.code
						}}</view>
						<view class="title u-line-2 add"><text class="font-weight-bold">制单时间：</text>{{ orderList.createtime
						}}</view>
						<view class="title u-line-2 add"><text class="font-weight-bold">客户名称 ：</text>{{
							orderList.customer_name
						}}</view>
						<text class="title u-line-2 add"><text class="font-weight-bold">类型：</text><text
								style="font-weight: 800;color: #409EFF;">{{ orderList.sell_type_str }}</text></text>
						<text class="title u-line-2 add"><text class="font-weight-bold">交货方式：</text><text
								style="font-weight: 800;color: #409EFF;">{{ orderList.type_str }}</text></text>
						<text class="title u-line-2 add"><text class="font-weight-bold">联 系 人 ：</text>{{
							orderList.customer_name
						}}</text>
						<text class="title u-line-2 add"><text class="font-weight-bold">联系电话：</text>{{ orderList.phone }}
							<text class="phone-fill"></text>
						</text>
						<view class="title  add"><text class="font-weight-bold">收货地址：</text>{{ orderList.city +
							orderList.address }}</view> -->


					<text class="title u-line-2 add phone-fill"><text class="font-weight-bold">付款形式 ：</text><text
							style="color: red;font-weight: 800;">{{ orderList.payment_status_str }}</text></text>
					<text v-if="orderList.payment_status == 0" class="title u-line-2 add"><text
							class="font-weight-bold">已收定金：</text>{{
								orderList.earnest_money }}</text>
					<view v-if="orderList.payment_status == 0">
						<text class="title u-line-2 add"><text class="font-weight-bold">尾款：</text>
							{{ Number(orderList.real_money) - Number(orderList.earnest_money) }}</text>
					</view>

					<!-- <text class="title u-line-2"><text class="font-weight-bold">交货方式：</text>{{ orderList.type||typelist[orderList.type].label }}</text> -->
					<!-- <text class="title u-line-2 add"><text class="font-weight-bold">产品总数：</text>{{ orderList.total_nums
						}}</text> -->

					<text class="title u-line-2 add phone-fill"><text class="font-weight-bold ">应付金额：</text>￥{{
						orderList.real_money
					}}</text>
					<br>
					<text class="title u-line-2 add"><text class="font-weight-bold">销售员 </text></text>
					<view class="producePerson">
						<view>
							<u-avatar :src="orderList.salespersonobj.avatar"></u-avatar>
						</view>
						<view>
							{{ orderList.salespersonobj.nickname }}
						</view>
						<view>
							电话：{{ orderList.salespersonobj.mobile }}
						</view>
					</view>
					<view class="title u-line-2 add"><text class="font-weight-bold">生产人员 </text></view>
					<view class="producePerson">
						<view>
							<u-avatar :src="orderList.productionpersonobj.avatar"></u-avatar>
						</view>
						<view>
							{{ orderList.productionpersonobj.nickname }}
						</view>
						<view>
							电话：{{ orderList.productionpersonobj.mobile }}
						</view>
					</view>

					<view class="" slot="body">
						<view class="title-wrap">
							<!-- 无三大件定制 -->
							<!-- <view v-if="orderList.sell_type == 0">
									<text class="title u-line-2 add"><text class="font-weight-bold">减震颜色：</text>{{
										orderList.shock_absorber_color }}</text>
									<text class="title u-line-2 add"><text class="font-weight-bold">卡钳颜色 ：</text>{{
										orderList.caliper_color }}</text>
									<text class="title u-line-2 add"><text class="font-weight-bold">轮毂颜色 ：</text>{{
										orderList.wheel_hub_color }}</text>
									<text class="title u-line-2 add"><text class="font-weight-bold">车壳颜色 ：</text>{{
										orderList.car_body_color }}</text>
								</view> -->

							<!-- 锂电池定制 -->
							<!-- <view v-if="orderList.sell_type == 1">
									<text class="title u-line-2 add"><text class="font-weight-bold">容量：</text>{{
										orderList.capacity }}</text>
									<text class="title u-line-2 add"><text class="font-weight-bold">车型：</text>{{
										orderList.car_model }}</text>
									<text class="title u-line-2 add"><text class="font-weight-bold">保护板：</text>{{
										orderList.protective_plate }}</text>
								</view> -->


							<text class="title u-line-2 add"><text class="font-weight-bold">邮寄方式 ：</text>{{
								orderList.mailing_type == 1 ? "包邮" : "到付" }}</text>
							<!-- <text class="title u-line-2 add"><text class="font-weight-bold">组装 ：</text>{{
									orderList.is_assemble_str }}</text> -->
							<!-- 提成 -->
							<view v-if="orderList.commission">
								<text class="title u-line-2 add"><text class="font-weight-bold">提成金额 ：</text>{{
									orderList.commission.commission_amount
								}}</text>
							</view>
							<text v-if="orderList.is_settlement == 0" class="title u-line-2 add"><text
									class="font-weight-bold">提成结算 ：</text>未结算</text>
							<text v-else class="title u-line-2 add"><text class="font-weight-bold">提成结算 ：</text>已结算</text>
							
							<text v-if="orderList.express_order" class="title u-line-2 add"><text v-if="orderList.express_order"  class="font-weight-bold">发货单号 ：</text>{{
									orderList.express_order }}</text>
							<!-- 提成 -->
							<view v-show="orderList.cause !== null">
								<text class="title u-line-2 add phone-fill"><text class="font-weight-bold">驳回原因：</text>{{
									orderList.cause }}</text>
							</view>

							<!-- 定金转账截图 -->

							<view class="cardbox" slot="body" v-if="orderList.payment_status == 0">
								<view class="right">
									<text class="title u-line-2"><text class="font-weight-bold">定金转账截图：</text></text>
								</view>
								<view class="left">
									<view class="img_box" v-for="(img, index) in orderList.earnest_money_imgs" :key="index"
										@click="previewImage(img, index)">
										<img :src="img">
									</view>
								</view>
							</view>

							<!-- 全款转账截图 -->
							<view class="cardbox" slot="body" v-else>
								<view class="right">
									<text class="title u-line-2"><text class="font-weight-bold">全款转账截图：</text></text>
								</view>
								<view class="left">
									<view class="img_box" v-for="(img, index) in orderList.full_payment_imgs" :key="index"
										@click="qkpreviewImage(img, index)">
										<img :src="img">
									</view>
								</view>
							</view>

							<!-- 尾款转账截图 -->
							<view class="cardbox" slot="body" v-if="orderList.balance_payment_imgs">
								<view class="right">
									<text class="title u-line-2"><text class="font-weight-bold">尾款转账截图：</text></text>
								</view>
								<view class="left">
									<view class="img_box" v-for="(img, index) in orderList.balance_payment_imgs"
										:key="index" @click="wkpreviewImage(img, index)">
										<img :src="img">
									</view>
								</view>
							</view>

							<!-- 发货图片 -->
							<view class="cardbox" slot="body" v-if="orderList.fhimg">
								<view class="right">
									<text class="title u-line-2"><text class="font-weight-bold">发货图片：</text></text>
								</view>
								<view class="left">
									<view class="img_box" v-for="(img, index) in orderList.fhimg" :key="index"
										@click="fhpreviewImage(img, index)">
										<img :src="img">
									</view>
								</view>
							</view>



						</view>
					</view>

					<!-- <view class="menu_item222" @click="$open('/pages/sell/xuanpei?id=' + id)"
									v-if="orderList.status >= 5">
									<text v-if="orderList.status >= 5">查看选配单</text>
								</view> -->

				</view>
			</view>
			<u-toast ref="uToast" />
		</view>
		<view class="menu-container">

			<view class="menu">
				<view class="title">
					<text class="u-text-center">操作</text>
				</view>
				<!-- <view class="menu_box"> -->
				<view class="menu_box">
					<!-- 发货时选择上传文字 -->
					<u-modal v-model="showFahuoText" :title-style="{ color: 'red' }" @confirm="uploadFahuoText"
						show-cancel-button>
						<view class="slot-content">
							<textarea class="texta" placeholder="请输入文字" v-model="fahuoText"></textarea>
						</view>
					</u-modal>

					<u-modal v-model="showWeikuang" :title-style="{ color: 'red' }" @confirm="rejectWeikuang"
						show-cancel-button>
						<view class="slot-content">
							<textarea class="texta" placeholder="请输入驳回理由" v-model="weikuangpasteText"></textarea>
						</view>
					</u-modal>
					<view class="shenhe">

						<u-modal v-model="showBohui" :title-style="{ color: 'red' }" @confirm="reject" show-cancel-button>
							<view class="slot-content">
								<textarea class="texta" placeholder="请输入驳回理由" v-model="pasteText"></textarea>
							</view>
						</u-modal>

						<u-modal v-model="showZuofei" :title-style="{ color: 'red' }" @confirm="zuofei" show-cancel-button>
							<view class="slot-content">
								<textarea class="texta" placeholder="请输入作废理由" v-model="zuofeipasteText"></textarea>
							</view>
						</u-modal>
						<u-popup v-model="showWeikuan" mode="bottom">
							<view class="uploadWeikuan">
								<view>上传尾款截图</view>
								<view class="upload-btn" style="width:100%">
									<cl-upload v-model="imagelist" :action="uploadUrl" @onSuccess="onSuccess"></cl-upload>
								</view>
							</view>
							<view class="cutLine"></view>
							<view>
								<u-button type="success" @click="uploadWk">上传</u-button>
							</view>
						</u-popup>
						<u-popup v-model="showFahuo" mode="bottom">
							<view class="uploadWeikuan">
								<view>上传发货图片</view>
								<view class="upload-btn" style="width:100%">
									<cl-upload v-model="fahuoImagelist" :action="uploadUrl"
										@onSuccess="fahuoOnSuccess"></cl-upload>
								</view>
							</view>
							<view class="cutLine"></view>
							<view>
								<u-button type="success" @click="uploadFahuo">上传</u-button>
							</view>
						</u-popup>


					</view>
					<view class="orderCz">
						<view class="menu_item" v-show="$rule('ordershanchu')" style="background-color: red;"
							@click="delOrder">
							<text v-show="$rule('ordershanchu')">删除</text>
						</view>
						<!-- 待财务审核返回的statsu是0 -->
						<view>
							<u-button v-show="$rule('sell/bohui') && orderList.status == 6" type="warning"
								@click="showWeikuang = true">驳回</u-button>
						</view>
						<view>
							<u-button v-show="$rule('sell/tongguo') && orderList.status == 6" type="success"
								@click="passWeikuang">通过</u-button>
						</view>
						<view>
							<u-button type="success" @click="showweikuanMethod"
								v-show="$rule('sell/weikuantu') && orderList.status == 5">上传尾款截图</u-button>

						</view>
						<view class="menu_item"
							v-show="$rule('sell/zuofei') && (orderList.status === 0 || orderList.status === 1 || orderList.status === 2 || orderList.status === 9 || orderList.status === 6 || orderList.status === 8)">
							<text @click="showZuofei = true"
								v-show="$rule('sell/zuofei') && (orderList.status === 0 || orderList.status === 1 || orderList.status === 2 || orderList.status === 9 || orderList.status === 6 || orderList.status === 8)">作废</text>
						</view>
						<view>
							<u-button type="warning" @click="caiwushenhe"
								v-show="$rule('sell/bohui') && orderList.status == 0">驳回</u-button>

						</view>
						<view>
							<u-button type="success" @click="pass"
								v-show="$rule('sell/tongguo') && orderList.status == 0">通过</u-button>
						</view>

						<view class="menu_item" @click="goodsok"
							v-show="$rule('dindanguanli/dindanwancheng') && (orderList.status === 9 || orderList.status === 10 || orderList.status === 11 || orderList.status === 12 || orderList.status === 13)">
							<text
								v-show="$rule('dindanguanli/dindanwancheng') && (orderList.status === 9 || orderList.status === 10 || orderList.status === 11 || orderList.status === 12 || orderList.status === 13)">订单完成</text>
						</view>
						<view class="menu_item" @click="gotoEdit(orderList.id)"
							v-show="$rule('sell/bianji') && orderList.status == -2">
							<text v-show="$rule('sell/bianji') && orderList.status == -2">编辑</text>
						</view>


						<view class="menu_item" @click="submitAudit"
							v-show="$rule('sell/tijiaoshenhe') && orderList.status == -2">
							<text>提交审核</text>


						</view>
						<view class="menu_item" @click="scComfirm"
							v-show="$rule('dindangguanli/shengchangqueren') && orderList.status == 2">
							<text v-show="$rule('dindangguanli/shengchangqueren') && orderList.status == 2">生产确认</text>
						</view>
						<view class="menu_item" @click="fanshenhe"
							v-show="$rule('dindangguanli/fanshenhe') && (orderList.status === 0 || orderList.status === 1 || orderList.status === 2 || orderList.status === 7 || orderList.status === 6 || orderList.status === 8)">
							<text
								v-show="$rule('dindangguanli/fanshenhe') && (orderList.status === 0 || orderList.status === 1 || orderList.status === 2 || orderList.status === 7 || orderList.status === 6 || orderList.status === 8)">反审核</text>
						</view>
						<!-- <view class="menu_item" @click="gotoEdit(orderList.id)"> -->
						<view class="menu_item" @click="$open('/pages/sell/optional?id=' + id)"
							v-show="$rule('sell/xuanpei') && orderList.status == 3">
							<text v-show="$rule('sell/xuanpei') && orderList.status == 3">选配</text>
						</view>

						<!-- 原发货按钮 -->
						<!-- <view class="menu_item" @click="fahuoMethod"
								v-show="$rule('sell/fahuo') && orderList.status == 9">
								<text v-show="$rule('sell/fahuo') && orderList.status == 9">发货</text>
							</view> -->

						<view class="menu_item" @click="sczzfinish"
							v-show="$rule('sell/wanchengzuzhuang') && orderList.status == 4">
							<text v-show="$rule('sell/wanchengzuzhuang') && orderList.status == 4">生产完成</text>
						</view>


						<!-- 新发货按钮 -->
						<view class="menu_item" @click="showFahuoMethod"
							v-show="$rule('sell/fahuo') && orderList.status == 9">
							<text v-show="$rule('sell/fahuo') && orderList.status == 9">发货</text>
						</view>




						<view class="menu_item"
							v-show="$rule('fafangticheng') && orderList.is_settlement == 0 && orderList.status == 14"
							@click="fafangticheng">
							<text
								v-show="$rule('fafangticheng') && orderList.is_settlement == 0 && orderList.status == 14">发放提成</text>
						</view>


					</view>
				</view>
				<!-- </view> -->
			</view>
		</view>
	</view>
</view></template>

<script>
var _this;
export default {
	data() {
		return {
			showFahuoText: false,
			fahuoText: '',
			showFahuo: false,
			fahuoImagelist: [],
			api_root2: '',
			imagelist: [],
			wkimagelist: [],
			uploadUrl: '',
			weikuangpasteText: '',
			showWeikuang: false,
			showWeikuan: false,
			zuofeipasteText: '',
			showZuofei: false,
			pasteText: '',
			showBohui: false,
			orderList: null,
			statusList: [
				{
					text: '待提交',
					type: 'info',
					index: -2

				}, {
					text: '待生产确认',
					type: 'error',
					index: 2

				}, {
					text: '待财务审核',
					type: 'info',
					index: 0

				}, {
					text: '财务审核失败',
					type: 'error',
					index: 1

				}, {
					text: '待选配',
					type: 'info',
					index: 3
				}, {
					text: '待生产完成',
					type: 'info',
					index: 4
				}, {
					text: '待付尾款',
					type: 'info',
					index: 5
				}, {
					text: '尾款待审核',
					type: 'info',
					index: 6
				}, {
					text: '尾款审核通过 ',
					type: 'success',
					index: 7
				}, {
					text: '尾款审核失败',
					type: 'error',
					index: 8
				}, {
					text: '待发货',
					type: 'info',
					index: 9
				}, {
					text: '已发货',
					type: 'success',
					index: 10
				}, {
					text: '已收货',
					type: 'success',
					index: 11
				}, {
					text: '发起退货',
					type: 'info',
					index: 12
				}, {
					text: '退货成功',
					type: 'success',
					index: 13
				}, {
					text: '订单完成',
					type: 'success',
					index: 14
				}, {
					text: '作废',
					type: 'error',
					index: -1
				}
			],
			typelist: [{
				label: '买家自提',
			}, {
				label: '卖家发货',
			}, {
				label: '代发',
			}],
			typelist: [{
				label: '买家自提',
			}, {
				label: '卖家发货',
			}, {
				label: '代发',
			}],
			id: null,
		}
	},
	onShow() {
		_this.getOrderList();
	},
	computed: {
		djsplitImages() {
			// 
			if (_this.orderList2 != undefined && _this.orderList2.balance_payment_imgs) {
				const img = _this.orderList2.balance_payment_imgs;

				const imglist = img.split(',');

				return imglist;
			} else {
				return []
			}
		},
		wksplitImages() {
			// 
			if (_this.orderList2 != undefined && _this.orderList2.balance_payment_imgs) {
				const img = _this.orderList2.balance_payment_imgs;

				const imglist = img.split(',');

				return imglist;
			} else {
				return []
			}
		}
	},
	onLoad(option) {
		_this = this;
		_this.id = option.id // 订单id
		_this.getOrderList();

		_this.api_root2 = _this.api_root.replace(/\/$/, '');
		_this.uploadUrl = _this.api_root + 'api/common/upload'
	},
	methods: {
		delOrder() {
			uni.showModal({
				title: '提示',
				content: '是否删除该订单？',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('api/ykjp/sell/Sell/del', {
							id: _this.id
						}, (result) => {
							if (result.code.result == 'success') {
								_this.$refs.uToast.show({
									title: '删除成功',
									type: 'success'
								})

								// 1秒后跳转
								setTimeout(() => {
									uni.redirectTo({ url: '/pages/order/order' })
								}, 1000);
							}
						});
					}

				}
			})
		},
		copyOrderInfo() {
			// 调用uni.setClipboardData方法将订单信息复制到剪贴板
			uni.setClipboardData({
				data: _this.orderList.remark,
				success() {
					uni.showToast({
						title: '复制成功',
						icon: 'success'
					});
				},
				fail() {
					uni.showToast({
						title: '复制失败',
						icon: 'none'
					});
				}
			});
		},
		showFahuoMethod() {
			// _this.showFahuo = true
			_this.showActionSheet()
		},
		showActionSheet() {
			uni.showActionSheet({
				itemList: ['上传文字', '上传图片'],
				success: (res) => {
					if (res.tapIndex >= 0 && res.tapIndex < 3) {
						// 用户选择了某个选项
						console.log('用户选择了选项' + (res.tapIndex + 1));
						if(res.tapIndex + 1 == 1){
							_this.showFahuoText = true
						} else {
							_this.showFahuo = true
						}
						

					} else if (res.tapIndex === 3) {
						// 用户选择了取消
						console.log('用户选择了取消');
					}
				}
			});
		},
		fafangticheng() {

			_this.$open('/pages/sell/sendCommission?id=' + _this.id)

		},
		// 刷新页面
		refresh() {

			// 等待1秒后刷新页面
			setTimeout(() => {
				uni.reLaunch(
					{
						url: '/pages/sell/orderdetail?id=' + _this.id
					}
				)
			}, 1000);

		},
		fhpreviewImage(index) {
			uni.previewImage({
				urls: _this.orderList.fhimg, // 构造完整的图片链接列表
				current: _this.orderList.fhimg[index] // 当前点击的图片链接
			});
		},
		wkpreviewImage(index) {
			uni.previewImage({
				urls: _this.orderList.balance_payment_imgs, // 构造完整的图片链接列表
				current: _this.orderList.balance_payment_imgs[index] // 当前点击的图片链接
			});
		},
		qkpreviewImage(index) {
			uni.previewImage({
				urls: _this.orderList.full_payment_imgs, // 构造完整的图片链接列表
				current: _this.orderList.full_payment_imgs[index] // 当前点击的图片链接
			});
		},
		previewImage(index) {
			uni.previewImage({
				urls: _this.orderList.earnest_money_imgs, // 构造完整的图片链接列表
				current: _this.orderList.earnest_money_imgs[index] // 当前点击的图片链接
			});
		},
		fahuoMethod() {
			_this.$open('/pages/sendGoods/sendGoods?id=' + _this.id)
		},
		caiwushenhe() {
			console.log('caiwushenhe')

			_this.showBohui = true
		},
		showweikuanMethod() {
			console.log('showweikuanMethod')
			_this.showWeikuan = true
		},
		goodsok() {
			uni.showModal({
				title: '提示',
				content: '该订单是否已完成？',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('api/ykjp/sell/Sell/goodsok', {
							id: _this.id
						}, (result) => {
							if (result.code.result == 'success') {
								// _this.showWeikuan = false
								_this.$refs.uToast.show({
									title: '订单已确认',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})
		},
		submitAudit() {
			uni.showModal({
				title: '提示',
				content: '是否提交审核？',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/submitAudit', {
							id: _this.id
						}, (result) => {
							if (result.code.result == 'success') {
								// _this.showWeikuan = false
								_this.$refs.uToast.show({
									title: '已确认',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})
		},
		sczzfinish() {
			uni.showModal({
				title: '提示',
				content: '是否已完成生产？',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/sczzfinish', {
							id: _this.id
						}, (result) => {
							if (result.code.result == 'success') {
								// _this.showWeikuan = false
								_this.$refs.uToast.show({
									title: '已确认',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})

		},
		// 生产人员确认
		scComfirm() {
			uni.showModal({
				title: '提示',
				content: '是否确认该订单？',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/scconfirm', {
							id: _this.id
						}, (result) => {
							if (result.code.result == 'success') {
								// _this.showWeikuan = false
								_this.$refs.uToast.show({
									title: '已确认',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})
		},
		fanshenhe() {

			uni.showModal({
				title: '提示',
				content: '是否反审核',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/Anti', {
							id: _this.id
						}, (result) => {

							if (result.code.result == 'success') {
								// _this.showWeikuan = false
								_this.$refs.uToast.show({
									title: '已反审核',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})



		},
		uploadFahuo() {
			let result = _this.fahuoImagelist.map(function (url) {
				// 检查url是否以_this.api_root开头
				if (url.startsWith(_this.api_root2)) {
					// 如果是，则截取_this.api_root之后的部分并返回
					return url.slice(_this.api_root2.length);
				} else {
					// 如果不是，则添加_this.api_root前缀并返回
					return url;
				}
			});

			console.log('%c [ result ]-664', 'font-size:13px; background:pink; color:#bf2c9f;', _this.fahuoImagelist)

			if (_this.fahuoImagelist.length !== 0) {

				_this._post_form('api/ykjp/sell/Sell/fahuo', {
					id: _this.id,
					fhimg: result
				}, (result) => {
					if (result.code.result == 'success') {
						_this.showFahuo = false
						_this.$refs.uToast.show({
							title: '上传成功',
							type: 'success'
						})
						_this.getOrderList();
					}
				});
			} else {
				// 提示不能上传空图片
				_this.$refs.uToast.show({
					title: '不能上传空图片',
					type: 'error'
				})

			}
		},
		uploadWk() {
			let result = _this.imagelist.map(function (url) {
				// 检查url是否以_this.api_root开头
				if (url.startsWith(_this.api_root2)) {
					// 如果是，则截取_this.api_root之后的部分并返回
					return url.slice(_this.api_root2.length);
				} else {
					// 如果不是，则添加_this.api_root前缀并返回
					return url;
				}
			});

			if (_this.imagelist.length !== 0) {
				_this._post_form('/api/ykjp/sell/Sell/uploadwkImg', {
					id: _this.id,
					balance_payment_imgs: result
				}, (result) => {
					if (result.code.result == 'success') {
						_this.showWeikuan = false
						_this.$refs.uToast.show({
							title: '上传成功',
							type: 'success'
						})
						_this.getOrderList();
					}
				});
			} else {
				// 提示不能上传空图片
				_this.$refs.uToast.show({
					title: '不能上传空图片',
					type: 'error'
				})
			}

		},

		fahuoOnSuccess(reslut) {
			_this.fahuoImagelist = Array.prototype.slice.call(_this.fahuoImagelist);

			// 把服务端返回的图片地址添加到list中与组件数据同步

			_this.fahuoImagelist.push(_this.api_root2 + reslut.data.url)

			// 提示不能上传空图片


		},
		onSuccess(reslut) {
			_this.imagelist = Array.prototype.slice.call(_this.imagelist);

			// 把服务端返回的图片地址添加到list中与组件数据同步
			_this.imagelist.push(_this.api_root2 + reslut.data.url)
		},
		zuofei() {


			if (_this.zuofeipasteText !== '') {

				_this._post_form('/api/ykjp/sell/Sell/abandon', {
					id: _this.id,
					reason: _this.zuofeipasteText
				}, (result) => {
					if (result.code.result == 'success') {
						_this.$refs.uToast.show({
							title: '已作废',
							type: 'success'
						})
					}
				});

			} else {
				console.log('请输入作废理由')
				_this.$refs.uToast.show({
					title: '请输入作废理由',
					type: 'error'
				})
			}
		},
		reject() {

			if (_this.pasteText !== '') {

				_this._post_form('/api/ykjp/sell/Sell/audit', {
					id: _this.id,
					act: 'reject',
					cause: _this.pasteText
				}, (result) => {
					if (result.code.result == 'success') {
						_this.$refs.uToast.show({
							title: '已驳回',
							type: 'success'
						})
						_this.refresh()
					}
				});

			} else {
				console.log('请输入驳回理由')
				_this.$refs.uToast.show({
					title: '请输入驳回理由',
					type: 'error'
				})
			}
		},
		uploadFahuoText() {


			if (_this.fahuoText !== '') {


				_this._post_form('api/ykjp/sell/Sell/fahuo', {
					id: _this.id,
					express_order: _this.fahuoText
				}, (result) => {
					if (result.code.result == 'success') {
						_this.showFahuo = false
						_this.$refs.uToast.show({
							title: '上传成功',
							type: 'success'
						})
						_this.getOrderList();
					}
				});

			} else {
				console.log('请输入文字')
				_this.$refs.uToast.show({
					title: '请输入文字！',
					type: 'error'
				})
			}
		},
		rejectWeikuang() {


			if (_this.weikuangpasteText !== '') {

				_this._post_form('/api/ykjp/sell/Sell/paymentAudit', {
					id: _this.id,
					act: 'reject',
					cause: _this.weikuangpasteText
				}, (result) => {
					if (result.code.result == 'success') {
						_this.$refs.uToast.show({
							title: '已驳回',
							type: 'success'
						})
						_this.refresh()
					}
				});

			} else {
				console.log('请输入驳回理由')
				_this.$refs.uToast.show({
					title: '请输入驳回理由',
					type: 'error'
				})
			}
		},
		passWeikuang() {
			uni.showModal({
				title: '提示',
				content: '是否通过审核',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/paymentAudit', {
							id: _this.id,
							act: 'pass'
						}, (result) => {
							if (result.code.result == 'success') {
								_this.$refs.uToast.show({
									title: '已通过',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})

		},
		pass() {
			uni.showModal({
				title: '提示',
				content: '是否通过审核',
				showCancel: true,
				success: ({ confirm, cancel }) => {
					if (confirm) {
						_this._post_form('/api/ykjp/sell/Sell/audit', {
							id: _this.id,
							act: 'pass'
						}, (result) => {
							if (result.code.result == 'success') {
								_this.$refs.uToast.show({
									title: '操作成功',
									type: 'success'
								})
								_this.refresh()
							}
						});
					}

				}
			})

		},
		gotoEdit(id) {
			uni.navigateTo({ url: `/pages/sell/editorder?id=${id}` })
		},
		getOrderList() {
			_this._post_form('/api/ykjp/sell/Sell/orderDetail', {
				id: _this.id
			}, (result) => {
				result.data.data.createtime = _this.transformTime(result.data.data.createtime);
				_this.setData({ 'orderList': result.data.data })
				_this.orderList2 = result.data.data
				console.log('%c [ _this.orderList2 ]-469', 'font-size:13px; background:pink; color:#bf2c9f;', _this.orderList2)
			});
		},
		makePhoneCall() {
			uni.makePhoneCall({
				phoneNumber: _this.orderList.phone //仅为示例
			});
		}
	}
}
</script>


<style scoped lang="scss">
.texta {
	min-height: 100px;
	width: 100%;
	background: #F9F9FB;
	padding-top: 20rpx;
	border-radius: 20rpx;
	white-space: pre-wrap;
}

.menu_item222 {
	padding: 10px;
	border-radius: 10px;
	margin-top: 20rpx;
	width: 200rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	color: #fff;
	background: #409EFF;
	font-weight: 500;
}

.weikuangsh {
	.weikuangbtn {
		display: flex;
		align-items: center;
		justify-content: space-around;
	}
}

.cutLine {
	height: 1px;
	background-color: #E5E5E5;
}

.uploadWeikuan {
	padding: 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 20px;
}


.menu-container {
	height: 140px;
}

.producePerson {
	margin-top: 20rpx;
	display: flex;
	align-items: center;
	justify-content: space-around;
	border-bottom: 1px solid #f5f5f5;
}

.orderinfo-contaienr {
	position: relative;
}

.menu_itemCopy-container {
	position: absolute;
	top: 30px;
	right: 10px;
}

.menu_itemCopy {
	padding: 10px;
	border-radius: 10px;
	text-decoration: underline;
	cursor: pointer;
	color: #409EFF;
	font-weight: 800;
}

.order_wrap {
	position: relative;

	.menu {
		z-index: 999999;
		position: fixed;
		bottom: 0;
		left: 0;
		padding-bottom: 20px;
		width: 100%;

		background: #fff;
		border-top: 1px solid #f5f5f5;
		// position: relative;
		padding: 10px;

		.ttile {
			position: absolute;
			top: 10px;
			left: 10px;

		}

		.menu_box {
			display: flex;
			justify-content: space-around;
			align-items: center;
			flex-direction: column;

			.shenhe {
				display: flex;
				width: 80%;
				justify-content: space-around;
			}

			.orderCz {
				display: flex;
				gap: 20rpx;
				flex-wrap: wrap;
			}

			.menu_item {
				padding: 10px;
				border-radius: 10px;
				background-color: #409EFF;
				color: #fff;
				font-weight: 800;
			}
		}

	}
}

.phone-fill {
	color: #ff070b;
}

.add {
	padding: 10px 0px;
	border-bottom: 1px solid #f5f5f5;
}


.cardbox {
	display: flex;
	gap: 10px;
	border-bottom: 1px solid #f5f5f5;
	margin-bottom: 20rpx;

	.left {
		img {
			width: 100px;
			height: 100px;
		}
	}

	.right {}
}
</style>
